﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.IDAL;
using System.Data;
using Register.DBUtility;
using Register.Model;
using System.Data.SqlClient;

namespace Register.DAL
{
    /// <summary>
    /// FileName: ModuleTopInfoDAL.cs
    /// CLRVersion: 4.0.30319.269
    /// Author: WangYan
    /// Corporation: 
    /// Description: 
    /// DateTime: 2012/6/24 19:23:38
    /// </summary>
    public class ModuleTopInfoDAL : IModuleTopInfoDAL
    {
        public List<Model.ModuleTopInfo> GetModuleTopInfos()
        {
            String sql = "select ModuleTop_ID,ModuleTop_Name from  System_moduleTopInfo order by ModuleTop_Num";

            DataSet ds = DbHelperSQL.Query(sql);

            return DataSetToList(ds);
        }
         public   List<Model.ModuleTopInfo> GetModuleTopInfosByID(String ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from System_moduleTopInfo ");
            strSql.Append(" where ModuleTop_ID=@ModuleTop_ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ModuleTop_ID", SqlDbType.Char,5)};
            parameters[0].Value = ID;
            DataSet ds = DbHelperSQL.Query(strSql.ToString(),parameters);
            return DataSetToList(ds);
        }
        private List<ModuleTopInfo> DataSetToList(DataSet ds)
        {
            List<ModuleTopInfo> list = new List<ModuleTopInfo>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                ModuleTopInfo mi=new ModuleTopInfo();
                mi.ModuleTop_ID=(String)row["ModuleTop_ID"];
                mi.ModuleTop_Name = (String)row["ModuleTop_Name"];
                list.Add(mi);
            }
            return list;
        }
    }
}
